package sumoTween.demo.swing.animated;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class DemoWindow extends JFrame{

	JButton button;
	DemoComponent demo;
	
	public DemoWindow()
	{
		demo=new DemoComponent();
		demo.setBounds(10, 10, 130,130);
		
		button=new JButton();
		button.setBounds(10, 150, 130, 20);
		button.setText(demo.getEasing().getClass().getSimpleName());
		this.add(button);

		this.setLayout(null);
		this.add(demo);
		
		this.setBounds(0, 0, 150, 220);
		this.setVisible(true);
		this.setTitle("sumoTween easings");		
		
		button.addMouseListener(new MouseListener() 
		{
			public void mouseReleased(MouseEvent e) {}
			public void mousePressed(MouseEvent e) {}
			public void mouseExited(MouseEvent e) {}
			public void mouseEntered(MouseEvent e) {}
			
			public void mouseClicked(MouseEvent e) 
			{
				demo.nextEasing();
				button.setText(demo.getEasing().getClass().getSimpleName());
			}
		});
		
        this.addWindowListener(new WindowListener() {
			
			public void windowOpened(WindowEvent e) {}
			public void windowIconified(WindowEvent e) {}
			public void windowDeiconified(WindowEvent e) {}
			public void windowDeactivated(WindowEvent e) {}
			public void windowClosed(WindowEvent e) {}
			public void windowActivated(WindowEvent e) {}
			public void windowClosing(WindowEvent e) 
			{
				System.exit(0);
			}
		});
		
    	boolean running=true;
		while(running)
		{
			try {
				Thread.sleep(20);
			} catch (Exception e) {
				// TODO: handle exception
			}
			
			repaint();
		}
		
	}
	
	
}
